<?
session_start();

$dni='43957385';

require("_db.inc");

switch ($_POST["enviar"]) {
case "Enviar datos": if ((($_POST["dni"]!=""))&&(($_POST["password"]!=""))) {
$conn=mysql_connect("localhost","chat001","caballos");
mysql_select_db("chat",$conn);
$query="select count(*) from vendedor where dni='".$_POST["dni"]."' and password='".$_POST["password"]."'";
$result=mysql_query($query);
if (mysql_result($result,0)) {
$accion="acceso";
$_SESSION["autenticado"]="S";
$dni=$_SESSION["dni"]=$_POST["dni"];
setcookie("recordar", md5("chat"), time()+3600);
} else {
$accion="no acceso";
}
} else {
$accion="sin acceso";
}
break;
default: if (($_SESSION["autenticado"]=="S")||($_COOKIE["recordar"]==md5("chat"))) {
require("_db.inc");
} else {
$accion="login";
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chat Sexshop Perú</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #333333;
}
body {
	background-color: #fcf6e8;
	background-image: url(imagenes/v_fondo_principal.gif);
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-repeat: repeat-y;
}
.nombreVendedora {
	font-size: 11px;
	color: #603913;
}
.nombreCliente {
	color: #790000;
	font-weight: bold;
}
.style1 {color: #77593F}
th {
color:#ef3436;
height:25px;
padding-top:5px
}
table.contenido {
font-weight:bold;
text-align:center;
width:450px;
margin:5px;
}
.espera {
	color: #009900;
	font-size: 10px;
}
-->
</style></head>
<body>
<table width="678" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="31" colspan="3" background="imagenes/v_fondo_menu.gif"><table width="593" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="158" background="imagenes/v_tienda.jpg"><div align="center" class="nombreCliente">Jr de la Unión</div></td>
          <td width="145"><img src="imagenes/v_conversaciones_on.jpg" width="145" height="31" /></td>
          <td width="145"><img src="imagenes/v_historico_off.jpg" width="145" height="31" onmouseout="javascript:this.src='imagenes/v_historico_off.jpg'" onmouseover="javascript:this.src='imagenes/v_historico_on.jpg'" /></td>
          <td width="145"><img src="imagenes/v_cambiar_password_off.jpg" width="145" height="31" onmouseout="javascript:this.src='imagenes/v_cambiar_password_off.jpg'" onmouseover="javascript:this.src='imagenes/v_cambiar_password_on.jpg'" /></td>
        </tr>
      </table></td>
    <td width="40" height="31" background="imagenes/v_fondo_menu.gif"><div align="right"><img src="imagenes/v_cerrar.jpg" width="38" height="31" /></div></td>
  </tr>
  <tr>
    <td colspan="4"><img src="imagenes/v_marco_superior.jpg" width="678" height="10" /></td>
  </tr>
  
  <tr>
    <td width="11">&nbsp;</td>
    <td width="469"><form name="formulario" action="" method="post"><table width="463" height="537" border="0" align="center" cellpadding="0" cellspacing="0" background="imagenes/v_marco_chico.gif">
      <tr>
        <td height="43"><div style="margin-left:15px"><strong>Filtrar por:</strong> 
            <label>solo activos
            <input name="filtro" type="radio" id="filtro" value="activo" checked="checked" />
            </label>
            <label>todos
            <input type="radio" name="filtro" id="filtro2" value="todos" />
            clientes no atendidos</label>
        <label>
            <input type="radio" name="filtro" id="filtro3" value="no atendidos" />
            </label>
        </div></td>
        </tr>
      <tr>
        <td height="446" valign="top"><div id="contenido" style="height:446px; overflow:auto"><table class="contenido" width="450" border="0" align="center" cellpadding="4" cellspacing="0">
  <tr style="background-color:#fadcb6">
    <th width="214">Cliente</th>
    <th width="48">Inicio</th>
    <th width="51">Fin</th>
    <th width="48">Total</th>
    <th width="94">Atendido</th>
  </tr>
<?
$query="select b.nombre,b.email,b.apellido,b.telefono,b.ubigeo,a.inicio r_inicio,time(a.inicio) inicio,a.fin,subtime(a.fin,a.inicio) minutos,a.productos,a.comentarios,a.atendido from conversacion a, cliente b where a.email=b.email and dni='$dni'";
$result=mysql_query($query);
while ($row=mysql_fetch_array($result, MYSQL_BOTH)) {
$nombre=$row["nombre"];
$email=$row["email"];
$apellido=$row["apellido"];
$telefono=$row["telefono"];
$ubigeo=$row["ubigeo"];
$r_inicio=$row["r_inicio"];
$inicio=$row["inicio"];
$fin=$row["fin"];
$minutos=$row["minutos"];
$productos=$row["productos"];
$comentarios=$row["comentarios"];
$atendido=$row["atendido"];
echo "<tr style='background-color:#fff99a'>";
echo "<td><a href='javascript:return false' onclick=\"javascript:window.open('http://chambaeschamba.com/chat-henry/chat/vv_chat.php?dni=$dni&inicio=$r_inicio&email=$email','chat_$email','width=530,height=450,scrollbars=no')\" >$nombre</a></td>";
echo "<td>$inicio</td>";
echo "<td>$fin</td>";
echo "<td>$minutos</td>";
if ($atendido=="No") {
echo "<td class='espera'>En espera</td>";
} else {
echo "<td class='espera'>Conversando</td>";
}
echo "</tr>";
}
?>
</table></div>
</td>
        </tr>
      <tr>
        <td><div style="margin-left:15px"><strong>Ordenar por:</strong> 
            <label>tiempo total
            <input name="orden" type="radio" id="filtro" value="tiempo" />
            </label>
            hora de inicio
            <label>
            <input type="radio" name="orden" id="filtro2" value="inicio" />
            nombre de cliente</label>
        <label>
            <input name="orden" type="radio" id="filtro3" value="nombre" checked="checked" />
            </label>
        </div></td>
        </tr>
    </table></form></td>
    <td colspan="2" valign="top"><div align="center">
      <p><img src="imagenes/v_producto.jpg" width="171" height="216" /></p>
      <p><img src="imagenes/logo.jpg" width="83" height="297" border="1" /></p>
    </div></td>
  </tr>
  
  <tr>
    <td colspan="4"><img src="imagenes/v_marco_inferior.jpg" width="678" height="10" /></td>
  </tr>
  <tr>
    <td bgcolor="#74593B"><span class="style1"><img src="imagenes/spacer.gif" width="1" height="5" /></span></td>
    <td bgcolor="#74593B"><span class="style1"></span></td>
    <td width="158" bgcolor="#74593B"><span class="style1"></span></td>
    <td bgcolor="#74593B"><span class="style1"></span></td>
  </tr>
</table>
</body>
</html>
